package com.sedu.manage.domain;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sedu.common.core.domain.entity.SysDept;
import com.sedu.common.core.domain.entity.SysUser;
import com.sedu.system.domain.SysPost;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.sedu.common.annotation.Excel;
import com.sedu.common.core.domain.BaseEntity;

/**
 * 课程管理对象 course
 *
 * @author yulinfeng
 * @date 2025-03-29
 */
public class Course extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 课程ID
     */
    private Long courseId;

    /**
     * 课程名
     */
    private String courseName;

    /**
     * 年级
     */
    @Excel(name = "年级")
    private Long deptId;


    /**
     * 年级对象
     */
    private SysDept dept;

    /**
     * 班级
     */
    @Excel(name = "班级")
    private Long postId;

    /**
     * 班级对象
     */
    private SysPost post;

    /**
     * 星期
     */
    @Excel(name = "星期")
    private Long dayOfWeek;

    /**
     * 课次
     */
    @Excel(name = "课次")
    private Long classOrder;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "HH:mm")
    @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm")
    private Date startTime;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "HH:mm")
    @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm")
    private Date endTime;

    /**
     * 学科
     */
    @Excel(name = "学科")
    private Long subjectId;

    /**
     * 学科对象
     */
    private Subject subject;

    /**
     * 教师
     */
    @Excel(name = "教师")
    private Long teacherId;

    /**
     * 教师名称
     */
    private String teacherName;

    /**
     * 教师对象
     */
    private SysUser teacher;

    public void setCourseId(Long courseId) {
        this.courseId = courseId;
    }

    public Long getCourseId() {
        return courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName() {
        // 如果存在dept年级对象、post班级对象、subject学科对象，则通过字符串拼接课程名
        String courseName = "";
        if (dept != null && post != null && subject != null) {
            courseName = dept.getDeptName() + post.getPostName() + "星期" + dayOfWeek + "第" + classOrder + "节" + subject.getSubjectName() + "课";
        }
        this.courseName = courseName;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public void setPostId(Long postId) {
        this.postId = postId;
    }

    public Long getPostId() {
        return postId;
    }

    public SysPost getPost() {
        return post;
    }

    public void setPost(SysPost post) {
        this.post = post;
    }

    public void setDayOfWeek(Long dayOfWeek) {
        this.dayOfWeek = dayOfWeek;
    }

    public Long getDayOfWeek() {
        return dayOfWeek;
    }

    public void setClassOrder(Long classOrder) {
        this.classOrder = classOrder;
    }

    public Long getClassOrder() {
        return classOrder;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setSubjectId(Long subjectId) {
        this.subjectId = subjectId;
    }

    public Long getSubjectId() {
        return subjectId;
    }

    public Subject getSubject() {
        return subject;
    }

    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    public void setTeacherId(Long teacherId) {
        this.teacherId = teacherId;
    }

    public Long getTeacherId() {
        return teacherId;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    public SysUser getTeacher() {
        return teacher;
    }

    public void setTeacher(SysUser teacher) {
        teacher.setPassword(null);
        this.teacher = teacher;
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("courseId", getCourseId())
                .append("deptId", getDeptId())
                .append("postId", getPostId())
                .append("dayOfWeek", getDayOfWeek())
                .append("classOrder", getClassOrder())
                .append("startTime", getStartTime())
                .append("endTime", getEndTime())
                .append("subjectId", getSubjectId())
                .append("teacherId", getTeacherId())
                .append("createTime", getCreateTime())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
